<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>字符串常用方法</title>
</head>
<body>
<script>
    var ss = "hello world 努力学习 abcdefg";
    //1 字符串截取 substr(index)  substr(index,num)  substring(index1,index2)
        console.log(ss.substr(5));  // 指定索引到结尾
        console.log(ss.substr(5,5)); //起始索引，截取个数
        console.log(ss.substring(5));
        console.log(ss.substring(5,7).length);


    //2 match --以数组的形式返回ss2中第一个和'hello'匹配的字符串/null
        var ss2 = "hello world,hello kitty";
//    var ss2 = " world, kitty";
   console.log(ss2.match('hello'));
//   alert(ss2.match('hello'));

    //    3 search-第一次出现的起始位置,未找到返回-1

   console.log(ss2.search('hello'));


    //    4 替换  ---替换第一个，不改变原数组
        console.log(ss2.replace("hello", "hi"));
        console.log(ss2);

    //    5 切割
    var str5 = "zhangsan,lisi,wangwu,zhaoliu";
    var arr = str5.split(',')
    console.log(arr)

    //    6 大小写
    var str6 = "wOmenDoushi";
    //    alert(str6.toLowerCase());
    //    alert(str6.toUpperCase());

</script>
</body>
</html>